package com.bdqn.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageSupport<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int totalPage; // 总页数
    private int currentPage; // 当前页数
    private int numberPage = 2; // 当前页面所显示的学生数量(默认为2位)
    private List<T> stu_list = new ArrayList<>(); // 记录每页学生

    public PageSupport() {
    }

    public PageSupport(int totalPage, int currentPage, int numberPage, List<T> stu_list) {
        this.totalPage = totalPage;
        this.currentPage = currentPage;
        this.numberPage = numberPage;
        this.stu_list = stu_list;
    }

    /**
     * 获取
     *
     * @return totalPage
     */
    public int getTotalPage() {
        return totalPage;
    }

    /**
     * 设置
     *
     * @param totalPage
     */
    public void setTotalPage(int totalPage) {
        if (totalPage % 2 == 0) {
            this.totalPage = totalPage / 2;
        } else {
            this.totalPage = totalPage / 2 + 1;
        }
    }

    /**
     * 获取
     *
     * @return currentPage
     */
    public int getCurrentPage() {
        return currentPage;
    }

    /**
     * 设置
     *
     * @param currentPage
     */
    public void setCurrentPage(int currentPage) {
        if (currentPage < totalPage + 1 && currentPage > 0) {
            this.currentPage = currentPage;
        }
    }

    /**
     * 获取
     *
     * @return numberPage
     */
    public int getNumberPage() {
        return numberPage;
    }

    /**
     * 设置
     *
     * @param numberPage
     */
    public void setNumberPage(int numberPage) {
        this.numberPage = numberPage;
    }

    /**
     * 获取
     *
     * @return stu_list
     */
    public List<T> getStu_list() {
        return stu_list;
    }

    /**
     * 设置
     *
     * @param stu_list
     */
    public void setStu_list(List<T> stu_list) {
        this.stu_list = stu_list;
    }

    public String toString() {
        return "Page{totalPage = " + totalPage + ", currentPage = " + currentPage + ", numberPage = " + numberPage + ", stu_list = " + stu_list + "}";
    }
}
